<template>
  <div id="assetMange">
    <!-- <div class="filterQuery">
      <div class="tiao">
        <span class="label">资产状态：</span>
        <el-radio-group v-model="radio" size="small">
          <el-radio-button label="待入池"></el-radio-button>
          <el-radio-button label="保存"></el-radio-button>
          <el-radio-button label="审核中"></el-radio-button>
          <el-radio-button label="打回修改"></el-radio-button>
          <el-radio-button label="审核通过"></el-radio-button>
          <el-radio-button label="无效"></el-radio-button>
        </el-radio-group>
      </div>
    </div> -->
    <div class="ruchi" style="margin-top: 10px;">
      <button @click="btnClick" class="btnru">资产入池</button>
      <el-button type="primary" style="float: right; transform: translate(-60px, 0px);" @click="look">查看资产池</el-button>
    </div>
    <div class="table">
      <el-table
        ref="multipleTable"
        :data="tableData"
        border
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center"></el-table-column>
        <el-table-column prop="receiveId" align="center" label="序号"></el-table-column>
        <el-table-column prop="sellCompany" align="center" label="债权人（卖方）"></el-table-column>
        <el-table-column prop="buyCompany" align="center" label="债务人（买方）"></el-table-column>
        <el-table-column prop="contractName" align="center" label="基础交易合同"></el-table-column>
        <el-table-column prop="receiveAmount" align="center" label="应收款金额"></el-table-column>
        <el-table-column prop="endDate" align="center" label="应收款到期日" :formatter="this.dateTable"></el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "assetMange",
  data() {
    return {
      radio: "",
      tableData: [],
      multipleSelection: [],
      currentPage: 1,
      total: null
    };
  },
  created () {
    this.getdata(1);
  },
  methods: {
    look () {
      this.$router.push('assetPool');
    },
    // 资产入池
    btnClick() {
      if (this.multipleSelection.length == 0) {
         this.$message({message: '请选择列表',type: 'warning'});
         return false;
      }
      let arrid = []
      this.multipleSelection.forEach((ele, index)=> {
        arrid.push(String(ele.receiveId));
      })
      this.axios.post('AdminAPI/assetManage/inPoolAsset', {inList: arrid})
        .then(({data})=> {
          if (data.code == 200) {
            this.$message({message: '提交成功',type: 'success'});
          }
        })
    },
    getdata(val) {
      let obj = {
        projectId: sessionStorage.getItem('swdypId'),
        page: this.currentPage
      }
      this.axios.get('AdminAPI/assetManage/getAssetManageList',{params: this.filterNoneObj(obj)})
        .then(({data})=> {
          this.tableData = data.data;
        })
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getdata(val);
    }
  }
};
</script>

<style lang="scss">
#assetMange {
  .filterQuery {
    margin-top: 10px;
    background: #e2eefd;
    padding-left: 34px;
    position: relative;
    .tiao {
      padding: 10px 0;
      .label {
        font-size: 20px;
        vertical-align: middle;
        color: #333333;
      }
      .el-radio-button__inner {
        border: none;
        padding: 6px 15px;
        background: none;
        font-size: 18px;
        border-radius: 0;
        margin-right: 15px;
      }
      .el-radio-button {
        &.is-active {
          span {
            background-color: #409eff !important;
          }
        }
      }
    }
  }
  .ruchi {
    text-align: center;
    background: white;
    padding: 30px 0px;
    .btnru {
      width: 174px;
      height: 40px;
      background: rgba(242, 146, 7, 1);
      border-radius: 6px;
      font-size: 22px;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
      cursor: pointer;
    }
  }
  .table {
    background: white;
    padding-top: 16px;
    .has-gutter tr th {
      background: #fefaf1;
    }
    .block {
      text-align: right;
      margin-right: 55px;
      height: 50px;
      margin-top: 20px;
    }
  }
}
</style>
